package main

import (
	"youdu/controller/freeipa"
	"youdu/controller/jielong"
	mockJielong "youdu/mock/jielong"

	"github.com/gin-gonic/gin"
)

func route(r *gin.Engine) {
	// home
	r.GET("/", func(ctx *gin.Context) {
		ctx.String(200, "Hello Youdu Plugins !")
	})
	// jielong
	r.GET("/jl/:x", jielong.ShowFromX)
	jl := r.Group("/jielong")
	{
		// page handler
		jl.GET("/", jielong.Index)
		jl.GET("/page/add", jielong.Add)
		jl.GET("/page/show/:id", jielong.Show)
		// api handler
		jl.GET("/api/Lists", jielong.Lists)
		jl.GET("/api/ListsOfParticipate", jielong.ListsOfParticipate)
		jl.GET("/api/ListItem/:id", jielong.ListItem)
		jl.GET("/api/ListItemWithUsers/:id", jielong.ListItemWithUsers)
		jl.POST("/api/ListAdd", jielong.ListAdd)
		jl.POST("/api/ListUpdate", jielong.ListUpdate)
		jl.GET("/api/ListDelete/:id", jielong.ListDelete)
		jl.GET("/api/ListUsers/:id", jielong.ListUsers)
		jl.POST("/api/ListUserAdd", jielong.ListUserAdd)
		jl.POST("/api/ListUserUpdate", jielong.ListUserUpdate)
		jl.GET("/api/ListUserDelete/:id", jielong.ListUserDelete)
		// mock handler
		jl.GET("/mock/ListUserAdd/:id", mockJielong.ListUserAdd)
	}

	// freeeipa
	r.POST("/ipa/auth", freeipa.UserAuth)
}
